<%--@elvariable id="typeValuesList" type="java.util.List"--%>
<%--@elvariable id="type" type="com.genghis.ptas.classify.entity.TypeValues"--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>

    <%@include file="../../common.jsp" %>
    <!-- BEGIN PAGE LEVEL STYLES -->
    <link rel="stylesheet" type="text/css" href="assets/plugins/select2/select2.css"/>
    <link rel="stylesheet" type="text/css" href="assets/plugins/select2/select2-metronic.css"/>
    <!-- END PAGE LEVEL SCRIPTS -->
    <!-- BEGIN THEME STYLES -->
    <link href="assets/css/style-metronic.css" rel="stylesheet" type="text/css"/>
    <link href="assets/css/style.css" rel="stylesheet" type="text/css"/>
    <link href="assets/css/style-responsive.css" rel="stylesheet" type="text/css"/>
    <link href="assets/css/plugins.css" rel="stylesheet" type="text/css"/>
    <link href="assets/css/custom.css" rel="stylesheet" type="text/css"/>

    <link href="assets/plugins/bootstrap-fileinput/bootstrap-fileinput.css" rel="stylesheet" type="text/css"/>
    <!-- END THEME STYLES -->
    <style type="text/css">
        .page-content {
            margin-left: 50px !important;
            width: 80%;
        }

        body {
            background-color: white !important;
        }
    </style>
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body>
<!-- BEGIN CONTENT -->
<div class="page-content">
    <div class="col-md-6">
        <!-- BEGIN FORM-->
        <form id="filegetup" method="post" enctype="multipart/form-data" class="form-horizontal" action="">
            <div class="form-body">
                <div class="form-group">
                    <label class="control-label col-md-4" for="courseName">课件名称： </label>

                    <div class="pull-right" style="width: 200px">
                        <input type="text" class="form-control" id="courseName" name="courseName"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-4" for="courseType">课件类型：</label>

                    <div class="pull-right">
                        <select id="courseType" style="width: 200px" name="courseType"
                                class="select2me">
                            <option value="">选择课件类型</option>
                            <c:forEach var="type" items="${typeValuesList}">
                                <option value="${type.id}">${type.typeValue}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-4" for="upFile">选择课件：</label>

                    <div class="pull-right" style="width: 200px">
                        <input type="file" class="form-control" id="upFile" name="upFile"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-4" for="fileImg">课件图片：</label>

                    <div class="fileinput fileinput-new pull-right" data-provides="fileinput">
                        <div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
                            <img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&amp;text=no+image"
                                 alt=""/>
                        </div>
                        <div class="fileinput-preview fileinput-exists thumbnail"
                             style="max-width: 200px; max-height: 150px;">
                        </div>
                        <div>
                                            <span class="btn default btn-file">
                                                <span class="fileinput-new">选择图片</span>
                                                <span class="fileinput-exists">修改</span>
                                                <input type="file" name="fileImg" id="fileImg">
                                            </span>
                            <a href="#" class="btn default fileinput-exists" data-dismiss="fileinput">
                                移除
                            </a>
                        </div>
                    </div>
                </div>
            </div>
            <div style="margin-left: 100px">
                <div class="col-md-6">
                    <a onclick="fileUpAttachment()" class="btn green">上传</a>
                    <a class="btn default" onclick="top.quit()">取消</a>
                </div>
            </div>
        </form>
        <!-- END FORM-->
    </div>
</div>
<!-- END CONTENT -->
<!--[if lt IE 9]>
<script src="assets/plugins/respond.min.js"></script>
<script src="assets/plugins/excanvas.min.js"></script>
<![endif]-->
<script src="assets/plugins/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js"
        type="text/javascript"></script>
<script src="assets/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery.blockui.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery.cokie.min.js" type="text/javascript"></script>
<script src="assets/plugins/uniform/jquery.uniform.min.js" type="text/javascript"></script>
<!-- END CORE PLUGINS -->
<!-- BEGIN PAGE LEVEL PLUGINS -->
<script type="text/javascript" src="assets/plugins/jquery-validation/dist/jquery.validate.min.js"></script>
<script type="text/javascript" src="assets/plugins/jquery-validation/dist/additional-methods.min.js"></script>
<script type="text/javascript" src="assets/plugins/select2/select2.min.js"></script>
<!-- END PAGE LEVEL PLUGINS -->
<!-- BEGIN PAGE LEVEL STYLES -->
<script src="assets/scripts/core/app.js" type="text/javascript"></script>
<script src="assets/scripts/custom/form-validation.js" type="text/javascript"></script>
<script type="text/javascript" src="assets/plugins/bootstrap-fileinput/bootstrap-fileinput.js"></script>
<script src="assets/plugins/bootbox/bootbox.min.js" type="text/javascript"></script>
<!-- END PAGE LEVEL STYLES -->

<script>
    jQuery(document).ready(function () {
        App.init();
        <%--@elvariable id="uploadResult" type="java.lang"--%>
        <%--@elvariable id="judge" type="java.lang"--%>
        <c:if test="${uploadResult}">
        if ("${type}" == "新增") {
            if (${judge}) {
                top.bootbox.alert("上传成功！");
                top.quit();
            } else {
                top.bootbox.alert("上传失败，请检查课件是否标准！");
            }
        } else {
            if (${judge}) {
                top.bootbox.alert("修改成功！");
                top.quit();
            } else {
                top.bootbox.alert("修改失败，请检查图片是否标准！");
            }
        }
        </c:if>
    });

    function fileUpAttachment() {
        var upFile = $("#upFile");
        var fileImg = $("#fileImg");
        if ("" == $("#courseName").val()) {
            top.bootbox.alert("课程名称不能为空！");
            return;
        }
        var courseType = $("#courseType").find("option:selected").val();
        if ("" == courseType) {
            top.bootbox.alert("课程类型不能为空！");
            return;
        }
        if ("" == upFile) {
            top.bootbox.alert("请选择上传课件！");
            return;
        }
        if ("" == fileImg) {
            top.bootbox.alert("请选择上传课件的图片！");
            return;
        }
        $("#filegetup").attr("action", "course/uploadByUser?upFile=" + upFile + "&fileImg=" + fileImg).submit();
    }

</script>
<!-- END JAVA_SCRIPTS -->
</body>
<!-- END BODY -->
</html>